package com.dingqb.ktdemo.oop

class OOPInterface {

}

interface Ibase {
    fun bar()
    fun foo()
    var age: Int
}

class ChildI : Ibase {
    override var age: Int = 10
    override fun bar() {
        println("bar ")
    }

    override fun foo() {
        println("foo")
    }


}

/**
 *函数扩功能
 */
public fun Student.getGrade(score: Float) = when (score) {
    in 90..100 -> "A"
    in 75..90 -> "B"
    in 60..75 -> "C"
    else -> "D"


}

fun main() {
    var cc = ChildI()
    cc.bar()
    cc.foo()
    println("${cc.age}")
    var stu = Student("zhangsan", 22);
    println(stu.getGrade(88F))
    printFoo(DD())

}

open class CC

class DD : CC()

fun CC.foo() = "cc"   // 扩展函数 foo

fun DD.foo() = "dd"   // 扩展函数 foo

fun printFoo(c: CC) {
    println(c.foo())  // 类型是 C 类
}

fun printFoo(c: DD) {
    println(c.foo())  // 类型是 C 类
}
